package com.zzb.controller;

import com.zzb.DTO.ResultDTO;
import com.zzb.VO.ProductVO;
import com.zzb.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/back/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @GetMapping("/all")
    public ResultDTO productFindAll(ProductVO productVO){
        return productService.findAll(productVO);
    }

    @PostMapping("/add")
    public ResultDTO productAdd(ProductVO productVO){
        return productService.add(productVO);
    }

    @GetMapping("/id")
    public ResultDTO productFindById(ProductVO productVO){
        return productService.findById(productVO);
    }

    @PostMapping("/update")
    public ResultDTO productUpdate(ProductVO productVO){
        return productService.update(productVO);
    }

    @PostMapping("/delete")
    public ResultDTO productDelete(ProductVO productVO){
        return productService.delete(productVO);
    }
}
